IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetAdvanceFundRequestUploadedDocumentByProposalNumber]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[GetAdvanceFundRequestUploadedDocumentByProposalNumber]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


--GetAdvanceFundRequestUploadedDocumentByProposalNumber '2009A050008'

CREATE PROCEDURE [dbo].[GetAdvanceFundRequestUploadedDocumentByProposalNumber] 
(  
	@PropNumber	VARCHAR(50)
)  
AS 

SET NOCOUNT ON
BEGIN  
		    
			SELECT CONVERT(VARCHAR(10), afud.DateUploaded,101) AS 'UploadedDate',
			adp.LastName + ', ' + adp.FirstName AS 'UploadedBy',
			DocumentName,
			FileUrl
			FROM  dbo.AdvanceFundRequestUploadedDocument AS afud	
			INNER JOIN AdmPerson AS adp ON adp.FwkDomainUserId = afud.UploadedBy 
			WHERE afud.PropNumber = @PropNumber
			ORDER BY afud.DateUploaded DESC

		  --PRINT(@OrderBy)

END



GO